|
|
@@ -9,6 +9,7 @@ import android.support.v4.app.FragmentManager;
|
9
|
9
|
import android.support.v4.app.FragmentTransaction;
|
10
|
10
|
import android.text.TextUtils;
|
11
|
11
|
import android.view.View;
|
|
12
|
+import android.widget.ImageButton;
|
12
|
13
|
import android.widget.ImageView;
|
13
|
14
|
import android.widget.TextView;
|
14
|
15
|
import android.widget.Toast;
|
|
|
@@ -29,7 +30,7 @@ import ai.pai.client.utils.SystemUtils;
|
29
|
30
|
import ai.pai.client.utils.UmengEvent;
|
30
|
31
|
import ai.pai.client.views.GroupQRPopup;
|
31
|
32
|
|
32
|
|
-public class GroupActivity extends BaseActivity implements View.OnClickListener{
|
|
33
|
+public class GroupActivity extends BaseActivity implements View.OnClickListener {
|
33
|
34
|
|
34
|
35
|
private String groupId;
|
35
|
36
|
private File photoFile;
|
|
|
@@ -37,47 +38,49 @@ public class GroupActivity extends BaseActivity implements View.OnClickListener{
|
37
|
38
|
private int defaultAvatarId;
|
38
|
39
|
private GroupQRFragment qrFragment;
|
39
|
40
|
private GroupPhotoFragment photoFragment;
|
40
|
|
-
|
|
41
|
+ private ImageButton cameraBtn;
|
41
|
42
|
private static final int TAKE_PHOTO_REQUEST_CODE = 1;
|
42
|
43
|
|
43
|
44
|
@Override
|
44
|
45
|
protected void onCreate(Bundle savedInstanceState) {
|
45
|
46
|
super.onCreate(savedInstanceState);
|
46
|
47
|
setContentView(R.layout.activity_group);
|
47
|
|
- SystemUtils.setImmerseLayout(this,findViewById(R.id.title_layout));
|
|
48
|
+ SystemUtils.setImmerseLayout(this, findViewById(R.id.title_layout));
|
48
|
49
|
dealIntentBundle(getIntent());
|
49
|
|
- TextView title = (TextView)findViewById(R.id.title_bar_middle_txt);
|
|
50
|
+ TextView title = (TextView) findViewById(R.id.title_bar_middle_txt);
|
50
|
51
|
title.setText(groupName);
|
51
|
|
- ImageView groupAvatar = (ImageView)findViewById(R.id.iv_title_bar_avatar);
|
52
|
|
- if(defaultAvatarId>=0){
|
|
52
|
+ ImageView groupAvatar = (ImageView) findViewById(R.id.iv_title_bar_avatar);
|
|
53
|
+ if (defaultAvatarId >= 0) {
|
53
|
54
|
groupAvatar.setImageResource(GroupCreateUtils.getDrawableIdForAvatar(defaultAvatarId));
|
54
|
|
- }else{
|
|
55
|
+ } else {
|
55
|
56
|
groupAvatar.setVisibility(View.GONE);
|
56
|
57
|
}
|
|
58
|
+ cameraBtn = (ImageButton) findViewById(R.id.floating_btn_camera);
|
|
59
|
+ cameraBtn.setOnClickListener(this);
|
57
|
60
|
findViewById(R.id.title_bar_back_layout).setOnClickListener(this);
|
58
|
61
|
findViewById(R.id.title_bar_option_layout).setOnClickListener(this);
|
59
|
62
|
findViewById(R.id.title_bar_qrcode_layout).setOnClickListener(this);
|
60
|
|
- findViewById(R.id.floating_btn_camera).setOnClickListener(this);
|
|
63
|
+ showMask();
|
61
|
64
|
}
|
62
|
65
|
|
63
|
|
- private void dealIntentBundle(Intent intent){
|
64
|
|
- if(intent.getSerializableExtra("group")==null){
|
|
66
|
+ private void dealIntentBundle(Intent intent) {
|
|
67
|
+ if (intent.getSerializableExtra("group") == null) {
|
65
|
68
|
groupName = intent.getStringExtra("name");
|
66
|
|
- defaultAvatarId = intent.getIntExtra("avatar",0);
|
|
69
|
+ defaultAvatarId = intent.getIntExtra("avatar", 0);
|
67
|
70
|
showQRFragment();
|
68
|
|
- }else{
|
|
71
|
+ } else {
|
69
|
72
|
GroupInfo info = (GroupInfo) intent.getSerializableExtra("group");
|
70
|
73
|
groupId = info.groupId;
|
71
|
74
|
groupName = info.groupName;
|
72
|
|
- if(TextUtils.isEmpty(groupName)){
|
|
75
|
+ if (TextUtils.isEmpty(groupName)) {
|
73
|
76
|
groupName = getString(R.string.default_group_name);
|
74
|
77
|
}
|
75
|
78
|
defaultAvatarId = info.groupAvatarId;
|
76
|
|
- if(!DBService.getInstance(this).isGroupExist(groupId)){
|
|
79
|
+ if (!DBService.getInstance(this).isGroupExist(groupId)) {
|
77
|
80
|
info.lastEnterTime = System.currentTimeMillis();
|
78
|
81
|
DBService.getInstance(this).addNewGroup(info);
|
79
|
|
- }else{
|
80
|
|
- DBService.getInstance(this).updateLastEnterTimeByGroupId(groupId,System.currentTimeMillis());
|
|
82
|
+ } else {
|
|
83
|
+ DBService.getInstance(this).updateLastEnterTimeByGroupId(groupId, System.currentTimeMillis());
|
81
|
84
|
}
|
82
|
85
|
showPhotoFragment();
|
83
|
86
|
}
|
|
|
@@ -85,32 +88,32 @@ public class GroupActivity extends BaseActivity implements View.OnClickListener{
|
85
|
88
|
|
86
|
89
|
@Override
|
87
|
90
|
public void onClick(View v) {
|
88
|
|
- switch (v.getId()){
|
|
91
|
+ switch (v.getId()) {
|
89
|
92
|
case R.id.title_bar_back_layout:
|
90
|
93
|
finish();
|
91
|
94
|
break;
|
92
|
95
|
case R.id.title_bar_option_layout:
|
93
|
96
|
MobclickAgent.onEvent(this, UmengEvent.group_setting_btn_click);
|
94
|
|
- Intent intent = new Intent(GroupActivity.this,GroupSettingActivity.class);
|
95
|
|
- intent.putExtra("group_id",groupId);
|
96
|
|
- intent.putExtra("avatar_id",defaultAvatarId);
|
97
|
|
- intent.putExtra("group_name",groupName);
|
|
97
|
+ Intent intent = new Intent(GroupActivity.this, GroupSettingActivity.class);
|
|
98
|
+ intent.putExtra("group_id", groupId);
|
|
99
|
+ intent.putExtra("avatar_id", defaultAvatarId);
|
|
100
|
+ intent.putExtra("group_name", groupName);
|
98
|
101
|
startActivity(intent);
|
99
|
102
|
break;
|
100
|
103
|
case R.id.floating_btn_camera:
|
101
|
104
|
MobclickAgent.onEvent(this, UmengEvent.group_camera_btn_click);
|
102
|
|
- if(TextUtils.isEmpty(groupId)){
|
103
|
|
- if(qrFragment!=null && qrFragment.isAdded()){
|
|
105
|
+ if (TextUtils.isEmpty(groupId)) {
|
|
106
|
+ if (qrFragment != null && qrFragment.isAdded()) {
|
104
|
107
|
groupId = qrFragment.getGroupId();
|
105
|
108
|
}
|
106
|
|
- if(TextUtils.isEmpty(groupId)){
|
107
|
|
- Toast.makeText(GroupActivity.this,R.string.group_detail_fetch_fail,Toast.LENGTH_SHORT).show();
|
108
|
|
- finish();
|
|
109
|
+ if (TextUtils.isEmpty(groupId)) {
|
|
110
|
+ Toast.makeText(GroupActivity.this, R.string.group_detail_fetch_fail, Toast.LENGTH_SHORT).show();
|
|
111
|
+ finish();
|
109
|
112
|
return;
|
110
|
113
|
}
|
111
|
114
|
}
|
112
|
115
|
|
113
|
|
- if(photoFragment==null){
|
|
116
|
+ if (photoFragment == null) {
|
114
|
117
|
showPhotoFragment();
|
115
|
118
|
}
|
116
|
119
|
photoFile = clickTakePhotoTab();
|
|
|
@@ -130,8 +133,8 @@ public class GroupActivity extends BaseActivity implements View.OnClickListener{
|
130
|
133
|
|
131
|
134
|
@Override
|
132
|
135
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
133
|
|
- if(resultCode== Activity.RESULT_OK && requestCode==TAKE_PHOTO_REQUEST_CODE){
|
134
|
|
- if(photoFragment!=null && photoFragment.isAdded()){
|
|
136
|
+ if (resultCode == Activity.RESULT_OK && requestCode == TAKE_PHOTO_REQUEST_CODE) {
|
|
137
|
+ if (photoFragment != null && photoFragment.isAdded()) {
|
135
|
138
|
// Intent intent = new Intent(this,PhotoUploadActivity.class);
|
136
|
139
|
// intent.putExtra("group_id",groupId);
|
137
|
140
|
// intent.putExtra("photo_path",photoFile.getAbsolutePath());
|
|
|
@@ -142,58 +145,80 @@ public class GroupActivity extends BaseActivity implements View.OnClickListener{
|
142
|
145
|
super.onActivityResult(requestCode, resultCode, data);
|
143
|
146
|
}
|
144
|
147
|
|
145
|
|
- private void uploadPhoto(String path){
|
146
|
|
- if(TextUtils.isEmpty(path)){
|
|
148
|
+ private void uploadPhoto(String path) {
|
|
149
|
+ if (TextUtils.isEmpty(path)) {
|
147
|
150
|
return;
|
148
|
151
|
}
|
149
|
152
|
|
150
|
153
|
Intent intent = new Intent(this, GroupService.class);
|
151
|
154
|
Bundle bundle = new Bundle();
|
152
|
155
|
bundle.putInt("command", GroupService.GroupCommand.COMMAND_UPLOAD_PHOTO);
|
153
|
|
- bundle.putString("group_id",groupId);
|
154
|
|
- bundle.putString("path",path);
|
|
156
|
+ bundle.putString("group_id", groupId);
|
|
157
|
+ bundle.putString("path", path);
|
155
|
158
|
intent.putExtras(bundle);
|
156
|
159
|
this.startService(intent);
|
157
|
160
|
}
|
158
|
161
|
|
159
|
|
- private File clickTakePhotoTab(){
|
|
162
|
+ private File clickTakePhotoTab() {
|
160
|
163
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
161
|
164
|
File dir = new File(Constants.APP_IMAGE_DIR);
|
162
|
165
|
dir.mkdirs();
|
163
|
|
- File photoFile = new File(dir.getAbsolutePath()+"/"+System.currentTimeMillis()+".jpg");
|
|
166
|
+ File photoFile = new File(dir.getAbsolutePath() + "/" + System.currentTimeMillis() + ".jpg");
|
164
|
167
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
|
165
|
|
- startActivityForResult(intent,TAKE_PHOTO_REQUEST_CODE);
|
|
168
|
+ startActivityForResult(intent, TAKE_PHOTO_REQUEST_CODE);
|
166
|
169
|
return photoFile;
|
167
|
170
|
}
|
168
|
171
|
|
169
|
|
- private void showQRFragment(){
|
|
172
|
+ private void showQRFragment() {
|
170
|
173
|
FragmentManager fm = getSupportFragmentManager();
|
171
|
174
|
FragmentTransaction ft = fm.beginTransaction();
|
172
|
|
- if(qrFragment==null){
|
|
175
|
+ if (qrFragment == null) {
|
173
|
176
|
qrFragment = new GroupQRFragment();
|
174
|
177
|
Bundle bundle = new Bundle();
|
175
|
|
- bundle.putString("name",groupName);
|
176
|
|
- bundle.putInt("avatar",defaultAvatarId);
|
|
178
|
+ bundle.putString("name", groupName);
|
|
179
|
+ bundle.putInt("avatar", defaultAvatarId);
|
177
|
180
|
qrFragment.setArguments(bundle);
|
178
|
|
- ft.add(R.id.content_fragment,qrFragment);
|
179
|
|
- }else{
|
|
181
|
+ ft.add(R.id.content_fragment, qrFragment);
|
|
182
|
+ } else {
|
180
|
183
|
ft.show(qrFragment);
|
181
|
184
|
}
|
182
|
185
|
ft.commitAllowingStateLoss();
|
183
|
186
|
}
|
184
|
187
|
|
185
|
|
- private void showPhotoFragment(){
|
|
188
|
+ private void showPhotoFragment() {
|
186
|
189
|
FragmentManager fm = getSupportFragmentManager();
|
187
|
190
|
FragmentTransaction ft = fm.beginTransaction();
|
188
|
|
- if(photoFragment==null){
|
|
191
|
+ if (photoFragment == null) {
|
189
|
192
|
photoFragment = new GroupPhotoFragment();
|
190
|
193
|
Bundle bundle = new Bundle();
|
191
|
|
- bundle.putString("groupId",groupId);
|
|
194
|
+ bundle.putString("groupId", groupId);
|
192
|
195
|
photoFragment.setArguments(bundle);
|
193
|
|
- ft.add(R.id.content_fragment,photoFragment);
|
194
|
|
- }else{
|
|
196
|
+ ft.add(R.id.content_fragment, photoFragment);
|
|
197
|
+ } else {
|
195
|
198
|
ft.show(photoFragment);
|
196
|
199
|
}
|
197
|
200
|
ft.commitAllowingStateLoss();
|
198
|
201
|
}
|
|
202
|
+
|
|
203
|
+ private void showMask() {
|
|
204
|
+ cameraBtn.postDelayed(new Runnable() {
|
|
205
|
+ @Override
|
|
206
|
+ public void run() {
|
|
207
|
+ runOnUiThread(new Runnable() {
|
|
208
|
+ @Override
|
|
209
|
+ public void run() {
|
|
210
|
+ int mHeight = getSupportActionBar().getHeight();
|
|
211
|
+ int left = cameraBtn.getLeft();
|
|
212
|
+ int right = cameraBtn.getRight();
|
|
213
|
+ int top = cameraBtn.getTop() + mHeight;
|
|
214
|
+ int bottom = cameraBtn.getBottom() + mHeight;
|
|
215
|
+ int loc[] = {left, top, right, bottom};
|
|
216
|
+ Intent intent = new Intent(GroupActivity.this, TipsActivity.class);
|
|
217
|
+ intent.putExtra("loc", loc);
|
|
218
|
+ startActivity(intent);
|
|
219
|
+ }
|
|
220
|
+ });
|
|
221
|
+ }
|
|
222
|
+ }, 500);
|
|
223
|
+ }
|
199
|
224
|
}
|